package com.ruoyi.user.controller.crm;

import com.ruoyi.common.core.annotation.valid.group.ValidGroup;
import com.ruoyi.common.core.constant.constant.PathConstant;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.user.model.pojo.request.crm.CrmDressAddOrEditRequest;
import com.ruoyi.user.model.pojo.request.crm.CrmDressSearchRequest;
import com.ruoyi.user.service.IDressService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;



@Tag(name = "CRM-装扮中心相关", description = "CRM-装扮中心相关")
@RestController
@RequestMapping(PathConstant.CRM_PATH + "dress")
public class CrmDressController {

    @Autowired
    private IDressService iDressService;

    @RequiresPermissions("system:dress:list")
    @Operation(description = "装扮列表", summary = "装扮列表")
    @GetMapping("listPage")
    public R listPage(CrmDressSearchRequest request) {
        return R.ok(iDressService.crmListPage(request));
    }

    @RequiresPermissions("system:dress:addOrEdit")
    @Operation(description = "添加编辑装扮", summary = "添加编辑装扮")
    @PostMapping("addOrEdit")
    public R addOrEdit(@RequestBody @Validated({ValidGroup.Update.class, ValidGroup.Insert.class}) CrmDressAddOrEditRequest request) {
        boolean add = iDressService.addOrEdit(request);
        return R.ok(add);
    }

    @RequiresPermissions("system:dress:delete")
    @Operation(description = "删除装扮", summary = "删除装扮")
    @GetMapping("del")
    public R del(Long id) {
        return R.ok(iDressService.removeById(id));
    }


}
